#include <tT.h>
#include <env.h>

#include "measure.h"

env_result_t measure_init(measure_t *self, void *none)
{
	ENV_DEBUG("enter measure_init()\r\n");
	
	/* Drive ports LOW UM p.126*/
	GPIO1->FIOCLR =	(1<<19) | 
				(1<<22) | 
				(1<<25) | 
				(1<<26) | 
				(1<<28) | 
				(1<<29);
	
	/* Set ports to output when in general mode p.123 */
	GPIO1->FIODIR |= 	(1<<19) |  	//MCOA0
				(1<<22) | 	//MCOB0
				(1<<25) | 	//MCOA1
				(1<<26) | 	//MCOB1
				(1<<28) | 	//MCOA2
				(1<<29);	//MCOB2
	
	PINCON->PINMODE3 |=	(3<<10); 	//DISABLE
	/*
	PINCON->PINSEL3 &= ~((3<<6) | 	//MCOA0
			 								 (3<<8) | 	//MCI0
											 (3<<10) | 	//MCABORT not available on 80-pin package
											 (3<<12) | 	//MCOB0
											 (3<<14) | 	//MCI1
											 (3<<16) | 	//MCI2
											 (3<<18) | 	//MCOA1
											 (3<<20) | 	//MC0B1
			  							 (3<<24) | 	//MCOA2
			   							 (3<<26));  //MCOB2
	*/
	/* Drive Current Reset pin LOW UM p.126*/
	GPIO1->FIOCLR = (1<<20);
	
	/* Set ports to output when in general mode p.123 */
	GPIO1->FIODIR |=  (1<<20);  	//CURRESET

	


	GPIO1->FIOSET = (1<<25) ; // Pull lower V-leg low

	return 0;
} 

